I report theoretical predictions of two models of donor-donor indirect interaction mediated by photons in zero- and two-dimensional cavities. These results are compared to previously studied cases of indirect interactions mediated by excitons and/or polaritons in bulk semiconductor and two-dimensional cavities. I find that photons mediate an Ising-like interaction between donors in the same manner polaritons do, in contrast to the Heisenberg-like interaction mediated by exciton. For the particular case of a two-dimensional cavity, the model shows that the dependence on distance of the donor-donor coupling constant is the same for photons and polaritons when the donor-donor distance is large. Then, it becomes clear that photons are responsible for the long range behavior of the polariton indirect interaction.